<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
@html_name: 14then方法
@description: The past cannot be redeemed, the future can be changed.
@author: Jason Black
@create: 2023/6/26 08:52:09
-->
<script>
  const p = new Promise((resolve,reject)=>{
    setTimeout(()=>{
      resolve("Jason")
    },1000)
  })
  //调用then方法then方法的返回结果是Promise对象，对象状态由回调函数的执行结果决定
  //1.如果回调函数中返回的结果是非promise类型的属性，状态为成功，返回值为对象的成功的值
  let p_ = p.then(value => {
    console.log(value)
    // throw "error"
    return new Promise((resolve, reject)=>{
      resolve("Jason")
    })
  },reason => {
    console.error(reason)
  })
  // 支持链式调用
  p.then(value => {
    console.log("then--1")
  }).then(value => {
    console.log("then--2")
  })
  console.log(p_)
</script>
</body>
</html>